package com.chhuang.ewcrm.cons;

import com.chhuang.ewcrm.bean.MainMenuBean;
import com.chhuang.ewcrm.bean.WeighTypeBean;
import com.chhuang.ewcrm.config.PropertiesUtil;
import com.chhuang.ewcrm.entity.SysUser;
import com.chhuang.ewcrm.utils.MyPath;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.LinkedList;
import java.util.List;

/**
 * @author chhuang
 * @create 2020-10-17-7:45
 */
public class Constants {
    private Constants(){}

    public static final String NO_SIGN_STR = "无信号";

    public static final String PROPERTIES_FILE_NAME = "config.properties";
    public static final String PROPERTIES_FILE_PATH = "config/config.properties";

    public static final String PS_BASE_URL_STR = "base_url";
    public static final String PS_API_URL_STR = "api_url";

    public static SysUser loginUser;

    public static final Integer CONFIG_ROOT_HEAD_HEIGHT = 128;

    public static final List<WeighTypeBean> WEIGH_TYPES = new LinkedList<>();
    public static final List<MainMenuBean> MAIN_MENUS = new LinkedList<>();

    static {
        String weighType = PropertiesUtil.getValue(PROPERTIES_FILE_PATH,"weigh_type");
        if(StringUtils.isNotEmpty(weighType)){
            String[] weighTypes = weighType.split(";");
            for (int i=0; i<weighTypes.length; i++) {
                WEIGH_TYPES.add(new WeighTypeBean(i, weighTypes[i]));
            }
        }

        String mainMenu = PropertiesUtil.getValue(PROPERTIES_FILE_PATH,"main_menu");
        if(StringUtils.isNotEmpty(mainMenu)){
            String[] mainMenus = mainMenu.split(";");
            for (int i=0; i<mainMenus.length; i++) {
                MAIN_MENUS.add(new MainMenuBean(i, mainMenus[i]));
            }
        }
    }
}
